package dca.sistemascontrole.view.estimacaoestado;

import javax.swing.WindowConstants;
import org.jfree.data.time.FixedMillisecond;

/**
 *
 * @author Teles
 */
public class FrameEstadoEstimado extends javax.swing.JDialog {

    private static FrameEstadoEstimado INSTANCE;

    private FrameEstadoEstimado(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();

        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    }

    @Override
    public void dispose() {
        setVisible(false);

        clear();
    }

    public void addValores(double nivelTanqueSuperiorEstimado, double nivelTanqueSuperiorMedido, double nivelTanqueInferiorEstimado, double nivelTanqueInferiorMedido, long t) {
        graficoTanqueInferior.addValue(nivelTanqueInferiorMedido, nivelTanqueInferiorEstimado, new FixedMillisecond(t));
        graficoTanqueSuperior.addValue(nivelTanqueSuperiorMedido, nivelTanqueSuperiorEstimado, new FixedMillisecond(t));
    }

    public static FrameEstadoEstimado getINSTANCE() {
        if (INSTANCE == null) {
            INSTANCE = new FrameEstadoEstimado(null, false);
        }

        return INSTANCE;
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        graficoTanqueSuperior = new dca.sistemascontrole.view.estimacaoestado.GraficoEstimacao();
        graficoTanqueInferior = new dca.sistemascontrole.view.estimacaoestado.GraficoEstimacao();
        chkExibirSuperiorMedido = new javax.swing.JCheckBox();
        chkExibirInferiorMedido = new javax.swing.JCheckBox();
        chkExibirSuperiorEstimado = new javax.swing.JCheckBox();
        chkExibirInferiorEstimado = new javax.swing.JCheckBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        graficoTanqueSuperior.setBackground(new java.awt.Color(255, 255, 255));
        graficoTanqueSuperior.setBorder(javax.swing.BorderFactory.createTitledBorder("Tanque Superior"));

        graficoTanqueInferior.setBackground(new java.awt.Color(255, 255, 255));
        graficoTanqueInferior.setBorder(javax.swing.BorderFactory.createTitledBorder("Tanque Inferior"));

        chkExibirSuperiorMedido.setSelected(true);
        chkExibirSuperiorMedido.setText("Exibir Nivel Tanque Superir Medido");
        chkExibirSuperiorMedido.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkExibirSuperiorMedidoActionPerformed(evt);
            }
        });

        chkExibirInferiorMedido.setSelected(true);
        chkExibirInferiorMedido.setText("Exibir Nivel Tanque Inferior Medido");
        chkExibirInferiorMedido.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkExibirInferiorMedidoActionPerformed(evt);
            }
        });

        chkExibirSuperiorEstimado.setSelected(true);
        chkExibirSuperiorEstimado.setText("Exibir Nivel Tanque Superior Estimado");
        chkExibirSuperiorEstimado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkExibirSuperiorEstimadoActionPerformed(evt);
            }
        });

        chkExibirInferiorEstimado.setSelected(true);
        chkExibirInferiorEstimado.setText("Exibir Nivel Tanque Inferior Estimado");
        chkExibirInferiorEstimado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkExibirInferiorEstimadoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(graficoTanqueInferior, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(graficoTanqueSuperior, javax.swing.GroupLayout.DEFAULT_SIZE, 854, Short.MAX_VALUE)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(chkExibirInferiorMedido)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(chkExibirInferiorEstimado))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(chkExibirSuperiorMedido)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(chkExibirSuperiorEstimado)))
                                .addGap(0, 0, Short.MAX_VALUE)))))
                .addContainerGap())
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {chkExibirInferiorEstimado, chkExibirInferiorMedido, chkExibirSuperiorEstimado, chkExibirSuperiorMedido});

        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(graficoTanqueSuperior, javax.swing.GroupLayout.DEFAULT_SIZE, 228, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(graficoTanqueInferior, javax.swing.GroupLayout.DEFAULT_SIZE, 228, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(chkExibirSuperiorMedido)
                    .addComponent(chkExibirSuperiorEstimado, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(chkExibirInferiorMedido)
                    .addComponent(chkExibirInferiorEstimado))
                .addContainerGap())
        );

        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void chkExibirSuperiorMedidoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkExibirSuperiorMedidoActionPerformed
        graficoTanqueSuperior.exibirMedido(chkExibirSuperiorMedido.isSelected());
    }//GEN-LAST:event_chkExibirSuperiorMedidoActionPerformed

    private void chkExibirSuperiorEstimadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkExibirSuperiorEstimadoActionPerformed
        graficoTanqueSuperior.exibirEstimado(chkExibirSuperiorEstimado.isSelected());
    }//GEN-LAST:event_chkExibirSuperiorEstimadoActionPerformed

    private void chkExibirInferiorMedidoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkExibirInferiorMedidoActionPerformed
        graficoTanqueInferior.exibirMedido(chkExibirInferiorMedido.isSelected());
    }//GEN-LAST:event_chkExibirInferiorMedidoActionPerformed

    private void chkExibirInferiorEstimadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkExibirInferiorEstimadoActionPerformed
        graficoTanqueInferior.exibirEstimado(chkExibirInferiorEstimado.isSelected());
    }//GEN-LAST:event_chkExibirInferiorEstimadoActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox chkExibirInferiorEstimado;
    private javax.swing.JCheckBox chkExibirInferiorMedido;
    private javax.swing.JCheckBox chkExibirSuperiorEstimado;
    private javax.swing.JCheckBox chkExibirSuperiorMedido;
    private dca.sistemascontrole.view.estimacaoestado.GraficoEstimacao graficoTanqueInferior;
    private dca.sistemascontrole.view.estimacaoestado.GraficoEstimacao graficoTanqueSuperior;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables

    public void clear() {
        graficoTanqueSuperior.clear();
        graficoTanqueInferior.clear();
    }
}
